package solution;

import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

public class DepthFirstOrderTest {
    @Test
    public void test(){
        //0: [1, 5, 6]
        //1: []
        //2: [0, 3]
        //3: [5]
        //4: []
        //5: [4]
        //6: [4, 9]
        //7: [6]
        //8: [7]
        //9: [10, 11, 12]
        //10: []
        //11: [12]
        //12: []
        Graph<Integer> digraph = new AdjacencyListDigraph<>();
        digraph.addEdge(0, 1);
        digraph.addEdge(0, 5);
        digraph.addEdge(0, 6);
        digraph.addEdge(2, 0);
        digraph.addEdge(2, 3);
        digraph.addEdge(3, 5);
        digraph.addEdge(5, 4);
        digraph.addEdge(6, 4);
        digraph.addEdge(6, 9);
        digraph.addEdge(7, 6);
        digraph.addEdge(8, 7);
        digraph.addEdge(9, 10);
        digraph.addEdge(9, 11);
        digraph.addEdge(9, 12);
        digraph.addEdge(11, 12);

        digraph.addVertex(1);
        digraph.addVertex(4);
        digraph.addVertex(10);
        digraph.addVertex(12);

        DepthFirstOrder<Integer> dfsOrder = new DepthFirstOrder<>(digraph);

        System.out.printf("dfs preorder: %s%n", dfsOrder.pre());

        System.out.printf("dfs postorder: %s%n", dfsOrder.post());

        System.out.printf("dfs reverse postorder: %s%n", dfsOrder.reversePost());



    }
}
